<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<title>${fns:getConfig('productName')}</title>
<meta name="decorator" content="blank" />
<c:set var="tabmode"
	value="${empty cookie.tabmode.value ? '0' : cookie.tabmode.value}" />
<c:if test="${tabmode eq '1'}">
	<link rel="Stylesheet"
		href="${ctxStatic}/jerichotab/css/jquery.jerichotab.css" />
	<script type="text/javascript"
		src="${ctxStatic}/jerichotab/js/jquery.jerichotab.js"></script>
</c:if>
<script src="<%=request.getContextPath()%>/static/layer/layer.js"></script>

<script type="text/javascript">
      var htm3="<object classid='CLSID:0CD890C1-2BDE-4096-A4B3-EEDA8DE5E18A' id='readerId' width='0' height='0'>"+
      "<p style='color: #FF0000;'>控件不可用，可能未正确安装控件及驱动，或者控件未启用。</p></object>"; 
      
      
      window.onload=function(){
    	  var str=window.navigator.userAgent.toLowerCase();
    	  var ds=document.getElementById('dk');
    	  if(str.indexOf('chrome')!=-1){
    		  
          }else if(str.indexOf('msie')!=-1){  
        	  ds.innerHTML=htm3;   
        	  READEROCX.Reader_Open(100,9600);//打开读卡器		
        	  READEROCX.Reader_Mode(0);
        	  
          }else{
        	  ds.innerHTML=htm3;
          }
      }
      
		</script>
<script type="text/javascript">

	function openDev(){
		var str=window.navigator.userAgent.toLowerCase();
		if(str.indexOf('msie')!=-1){
			READEROCX = document.getElementById("readerId"); 
			READEROCX.Reader_Open(100,9600);//打开读卡器	
			READEROCX.Reader_Mode(0);
        }
	}
	
	function changeMode(){
		READEROCX = document.getElementById("readerId"); 
		READEROCX.Reader_Open(100,9600);//打开读卡器	
		READEROCX.Reader_Mode(0);
		alert("READEROCX.LastRet=="+READEROCX.LastRet);
		 if (READEROCX.LastRet != 0) {
             msg.value = "切换只读模式失败" + "\n";
             return;
         }
		 alert("切换只读模式成功！");
	}
	
	 //打开读写器
       function saveCardWin() {
    	   READEROCX = document.getElementById("readerId"); 
    	  // alert(READEROCX);
           var version = READEROCX.Reader_Open(100,9600); //打开USB设备
           if (READEROCX.LastRet != 0) {
               msg.value = "打开读写器失败" + "\n";
               return;
           }
           READEROCX.Reader_Mode(1);
           alert("打开读卡器成功,请放卡！");
       }
    
 function writeCard(){
	 READEROCX = document.getElementById("readerId"); 
	   var personid=top.frames["mainFrame"].document.getElementById("personid").value;
	   			READEROCX.Reader_Open(100,9600);//打开读卡器
				READEROCX.Reader_Mode(1);//写卡之前要切换到读写模式  1-读写 0-只读			
	            READEROCX.Card_Open(1, 0);  // 打开卡片,以10进制字符串显示卡号
	            READEROCX.Reader_LoadKey(0, 2, "632017091269");
			    READEROCX.Mifare_Authentication(0, 2);
			 if(READEROCX.LastRet != 0){
				alert("验证卡片密码失败！");
				READEROCX.Reader_Open(100,9600);//打开读卡器
				READEROCX.Reader_Mode(0);
				 return false;
			 }else{
				 READEROCX.Mifare_Write(8, personid.substring(0, 16));//往卡里写数据，只能写16个字符
				 
		 				if(READEROCX.LastRet != 0){
						alert("写卡 失败！");
						READEROCX.Reader_Open(100,9600);//打开读卡器
						READEROCX.Reader_Mode(0);
						 return false;
					}else{
						 READEROCX.Reader_LoadKey(0, 2, "632017091269");
						 READEROCX.Mifare_Authentication(0, 2);
						 READEROCX.Mifare_Write(9, personid.substring(16, 32));//往卡里写数据，只能写16个字符
						 
							 if(READEROCX.LastRet != 0){
								alert("写卡 失败！");
								READEROCX.Reader_Open(100,9600);//打开读卡器
								READEROCX.Reader_Mode(0);
								 return false;
							}else{
								READEROCX.Reader_LoadKey(0, 2, "632017091269");
								READEROCX.Mifare_Authentication(0, 2);
								READEROCX.Mifare_Write(10,personid.substring(32, 48));//往卡里写数据，只能写16个字符
			 					if(READEROCX.LastRet != 0){
									alert("写卡失败！");
									READEROCX.Reader_Open(100,9600);//打开读卡器
									READEROCX.Reader_Mode(0);
									 return false;
								}else{
									 //check=true;
									 READEROCX.Reader_Open(100,9600);//打开读卡器
									 READEROCX.Reader_Mode(0);
									 return true;
									 
								} 
						} 
					} 
				 
				 } 
			 READEROCX.Reader_Open(100,9600);//打开读卡器
			 READEROCX.Reader_Mode(0);
			 
   }
   
   		function showCardWin(){
   			
   			layer
			.open({
				type : 1,
				skin : 'layui-layer-rim', // 加上边框
				area : [ '600px',
						'200px' ],
						
				title : "<font style='color:red;font-size:12px;'>*打卡期间请勿关闭此窗口,请勿移动光标*</font>",	
				
				content : "<div align='center' style='padding: 20px 40px;'>"
						+ "<font  style='color:blue;font-size:40px;'>>>>>>>请刷卡<<<<<<</font>"
						+ "<input id='_cardInput' type='text'  style='border:none;width:1px;padding:0px;'></div>"
						+ "<div style='text-align:center'>"
						+"</div>",
						end: function(){  
							//READEROCX.Reader_Open(100,9600);//打开读卡器
							//READEROCX.Reader_Mode(1);
							//READEROCX.Reader_Close();
	                    }  
			});
 			$("#_cardInput").focus();
			$("#_cardInput").blur(function(){
				$("#_cardInput").focus();
			});
			
			 $(document).mousedown(function(event){
				$("#_cardInput").focus();
			}); 
			var alertIndex = null;
			$("#_cardInput").bind('change',function(){
				var val = $("#_cardInput").val();
				
				//top.frames["mainFrame"].document.getElementById("xgBtn1").click();
 				//alert(top.frames["mainFrame"].document.getElementById("_dyqd_text"));
				//var dyqd = top.frames["mainFrame"].document.getElementById("_dyqd_text").innerText;
 				//alert(dyqd);
				//if(dyqd == null || dyqd == ""){
					top.frames["mainFrame"].document.getElementById("pid").value = val;
					top.frames["mainFrame"].$("#_card_child").click();
				//	top.$("#_card_win").click();

				//}else{
				//	top.frames["mainFrame"].document.getElementById("_dyqd_text").innerText = dyqd+","+val;
			//	}
				$("#_cardInput").val("");
				
// 				layer.closeAll();
			});
   		}
   		function sucess(){
   			layer.msg('<div align="center" style="line-height:240px;"><font style="color:red;font-size:60px;">签到成功!</font></div>', {
				area : [ '620px',
					'300px' ],
					icon:1,
				time: 3000 // 3s后自动关闭
  			});
   		}
   		function sucess1(personName){
   			layer.msg('<div align="center" style="line-height:240px;"><font style="color:red;font-size:60px;">'+personName+'测试成功!</font></div>', {
				area : [ '620px',
					'300px' ],
					icon:1,
				time: 3000 // 3s后自动关闭
  			});
   		}
   		function error(){
   			layer.msg('<div align="center" style="line-height:240px;"><font style="color:red;font-size:60px;">党员已签到!</font></div>', {
				area : [ '620px',
					'300px' ],
					icon:1,
				time: 3000 // 3s后自动关闭
  			});
   		}
   		function error1(){
   			layer.msg('<div align="center" style="line-height:240px;"><font style="color:red;font-size:60px;">党员卡无效!</font></div>', {
				area : [ '620px',
					'300px' ],
					icon:2,
				time: 3000 // 3s后自动关闭
  			});
   		}
   		function error2(){
   			layer.msg('<div align="center" style="line-height:240px;"><font style="color:red;font-size:30px;">签到失败,此卡未在本支部开卡!</font></div>', {
				area : [ '620px',
					'300px' ],
					icon:2,
				time: 3000 // 3s后自动关闭
  			});
   		}
   </script>
<style type="text/css">
#main {
	padding: 0;
	margin: 0;
}

#main .container-fluid {
	padding: 0 4px 0 6px;
}

#header {
	margin: 0 0 8px;
	position: static;
}

#header li {
	font-size: 14px;
	_font-size: 12px;
}

#header .brand {
	font-family: Helvetica, Georgia, Arial, sans-serif, 黑体;
	font-size: 26px;
	padding-left: 33px;
}

#footer {
	margin: 8px 0 0 0;
	padding: 3px 0 0 0;
	font-size: 11px;
	text-align: center;
	border-top: 2px solid #0663A2;
}

#footer, #footer a {
	color: #999;
}

#left {
	overflow-x: hidden;
	overflow-y: auto;
}

#left .collapse {
	position: static;
}

#userControl>li>a { /*color:#fff;*/
	text-shadow: none;
}

#userControl>li>a:hover, #user #userControl>li.open>a {
	background: transparent;
}
</style>
<script type="text/javascript">
		$(document).ready(function(){
			// <c:if test="${tabmode eq '1'}"> 初始化页签
			$.fn.initJerichoTab({
                renderTo: '#right', uniqueId: 'jerichotab',
                contentCss: { 'height': $('#right').height() - tabTitleHeight },
                tabs: [], loadOnce: true, tabWidth: 110, titleHeight: tabTitleHeight
            });//</c:if>
			// 绑定菜单单击事件
			$("#menu a.menu").click(function(){
				// 一级菜单焦点
				$("#menu li.menu").removeClass("active");
				$(this).parent().addClass("active");
				// 左侧区域隐藏
				if ($(this).attr("target") == "mainFrame"){
					$("#left,#openClose").hide();
					wSizeWidth();
					// <c:if test="${tabmode eq '1'}"> 隐藏页签
					$(".jericho_tab").hide();
					$("#mainFrame").show();//</c:if>
					return true;
				}
				// 左侧区域显示
				$("#left,#openClose").show();
				if(!$("#openClose").hasClass("close")){
					$("#openClose").click();
				}
				// 显示二级菜单
				var menuId = "#menu-" + $(this).attr("data-id");
				if ($(menuId).length > 0){
					$("#left .accordion").hide();
					$(menuId).show();
					// 初始化点击第一个二级菜单
					if (!$(menuId + " .accordion-body:first").hasClass('in')){
						$(menuId + " .accordion-heading:first a").click();
					}
					if (!$(menuId + " .accordion-body li:first ul:first").is(":visible")){
						$(menuId + " .accordion-body a:first i").click();
					}
					// 初始化点击第一个三级菜单
					$(menuId + " .accordion-body li:first li:first a:first i").click();
				}else{
					// 获取二级菜单数据
					$.get($(this).attr("data-href"), function(data){
						if (data.indexOf("id=\"loginForm\"") != -1){
							alert('未登录或登录超时。请重新登录，谢谢！');
							top.location = "${ctx}";
							return false;
						}
						$("#left .accordion").hide();
						$("#left").append(data);
						// 链接去掉虚框
						$(menuId + " a").bind("focus",function() {
							if(this.blur) {this.blur()};
						});
						// 二级标题
						$(menuId + " .accordion-heading a").click(function(){
							$(menuId + " .accordion-toggle i").removeClass('icon-chevron-down').addClass('icon-chevron-right');
							if(!$($(this).attr('data-href')).hasClass('in')){
								$(this).children("i").removeClass('icon-chevron-right').addClass('icon-chevron-down');
							}
						});
						// 二级内容
						$(menuId + " .accordion-body a").click(function(){
							$(menuId + " li").removeClass("active");
							$(menuId + " li i").removeClass("icon-white");
							$(this).parent().addClass("active");
							$(this).children("i").addClass("icon-white");
						});
						// 展现三级
						$(menuId + " .accordion-inner a").click(function(){
							var href = $(this).attr("data-href");
							if($(href).length > 0){
								$(href).toggle().parent().toggle();
								return false;
							}
							// <c:if test="${tabmode eq '1'}"> 打开显示页签
							return addTab($(this)); // </c:if>
						});
						// 默认选中第一个菜单
						$(menuId + " .accordion-body a:first i").click();
						$(menuId + " .accordion-body li:first li:first a:first i").click();
					});
				}
				// 大小宽度调整
				wSizeWidth();
				return false;
			});
			// 初始化点击第一个一级菜单
			$("#menu a.menu:first span").click();
			// <c:if test="${tabmode eq '1'}"> 下拉菜单以选项卡方式打开
			$("#userInfo .dropdown-menu a").mouseup(function(){
				return addTab($(this), true);
			});// </c:if>
			// 鼠标移动到边界自动弹出左侧菜单
			$("#openClose").mouseover(function(){
				if($(this).hasClass("open")){
					$(this).click();
				}
			});
			// 获取通知数目  <c:set var="oaNotifyRemindInterval" value="${fns:getConfig('oa.notify.remind.interval')}"/>
			function getNotifyNum(){
				$.get("${ctx}/oa/oaNotify/self/count?updateSession=0&t="+new Date().getTime(),function(data){
					var num = parseFloat(data);
					if (num > 0){
						$("#notifyNum,#notifyNum2").show().html("("+num+")");
					}else{
						$("#notifyNum,#notifyNum2").hide()
					}
				});
			}
			getNotifyNum(); //<c:if test="${oaNotifyRemindInterval ne '' && oaNotifyRemindInterval ne '0'}">
			setInterval(getNotifyNum, ${oaNotifyRemindInterval}); //</c:if>
		});
		// <c:if test="${tabmode eq '1'}"> 添加一个页签
		function addTab($this, refresh){
			$(".jericho_tab").show();
			$("#mainFrame").hide();
			$.fn.jerichoTab.addTab({
                tabFirer: $this,
                title: $this.text(),
                closeable: true,
                data: {
                    dataType: 'iframe',
                    dataLink: $this.attr('href')
                }
            }).loadData(refresh);
			return false;
		}// </c:if>
	</script>
<style type="text/css">
.nav-list>.active>a, .nav-list>.active>a:hover, .nav-list>.active>a:focus
	{
	color: #fff;
	text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.2);
	background-color: #E91B1B;
}

a:hover {
	color: #666
}

.main-toolbar .main-toolbar-item .ass {
	font-size: 12px;
	color: #666;
}

.ass :hover {
	color: #fff;
	background: #E91B1B;
}
</style>
<link rel="Stylesheet" href="${ctxStatic}/jerichotab/css/base.css" />

</style>
<link rel="Stylesheet" href="${ctxStatic}/jerichotab/css/base.css" />
<link href="${ctxStatic}/images/dangjian-favicon.ico" rel="icon"
	type="image/x-icon" />
</head>
<body>
	<div id="dk"></div>

	<div class="layout-top">

		<div class="layout-top-wave" id="topwave"
			style="transform: translate3d(0px, 0px, 0px); transform-style: preserve-3d; backface-visibility: hidden;">
			<div class="layer topwave wave1" data-depth="0.02"
				style="transform: translate3d(1.532px, -0.165921px, 0px); transform-style: preserve-3d; backface-visibility: hidden; position: relative; display: block; left: 0px; top: 0px;"></div>
			<div class="layer topwave wave2" data-depth="0.08"
				style="transform: translate3d(6.128px, -0.663683px, 0px); transform-style: preserve-3d; backface-visibility: hidden; position: absolute; display: block; left: 0px; top: 0px;"></div>
			<div class="layer topwave wave3" data-depth="0.14"
				style="transform: translate3d(10.724px, -1.16144px, 0px); transform-style: preserve-3d; backface-visibility: hidden; position: absolute; display: block; left: 0px; top: 0px;"></div>
			<div class="layer topwave wave4" data-depth="0.20"
				style="transform: translate3d(15.32px, -1.65921px, 0px); transform-style: preserve-3d; backface-visibility: hidden; position: absolute; display: block; left: 0px; top: 0px;"></div>
		</div>
		<div id="J_header">
			<div class="logo" style='width: 500px'>
				<h1 style='margin-top: 15px;'>
					<a href="#"><img style='width: 400px; height: 60px;'
						src="${ctxStatic}/jerichotab/img/qdLogo.png" alt=""></a>
				</h1>
			</div>
			<div class="sub-title pull-left" style="line-height: 88px;">
				<h2
					style="line-height: 84px; color: #fff; font-weight: bolder; font-family: microsoft yahei; font-size: 22px; margin-left: 20px; letter-spacing: 2px; text-shadow: 0 1px 2px rgba(0, 0, 0, .4);"></h2>
			</div>
			<ul class="main-toolbar">
				<li class="main-toolbar-item"><a class="user-bar"
					href="javascript:void(0)">
						<div class="user-img m-r-sm">
							<img src="${ctxStatic}/jerichotab/img/userimg.png" alt="">
						</div>
						<div class="user-info">
							<p>
								<span class="user-name">${fns:getUser().name}</span>
							</p>
							<p>
								<i class="icons-12 icons-12-date m-r-xs"></i>最后登录日期：
								<fmt:formatDate value="${fns:getUser().loginDate}" type="date"
									pattern="yyyy-MM-dd hh:mm:ss" />
							</p>
						</div>
				</a></li>

				<li class="main-toolbar-item main-btn-holder">
					<div data-toggle="dropdown" class="enter-button ">
						<a aria-haspopup="true" aria-expanded="false"
							class="avatar dropdown-toggle"> <i
							class="icons-32 icons-32-gear"></i>
						</a>
					</div>
					<ul style="margin-left: -30px; min-width: 100px"
						class="dropdown-menu">
						<!--                         <li> -->
						<!--                             <a id="g-change-pwd" class='ass' href="#"  data-toggle="modal" data-target="#modal-2">修改密码</a> -->
						<!--                         </li> -->
						<li><a class='ass' href="${ctx}/logout">退出登录</a></li>
					</ul>
				</li>
			</ul>
		</div>
	</div>
	<!------------------------------导航开始------------------------------>

	<div id="main">
		<div id="header" class="navbar navbar-fixed-top">

			<%-- <c:if test="${cookie.theme.value eq 'cerulean'}">
					<div id="user" style="position:absolute;top:0;right:0;"></div>
					<div id="logo" style="background:url(${ctxStatic}/images/logo_bg.jpg) right repeat-x;width:100%;">
						<div style="background:url(${ctxStatic}/images/logo.jpg) left no-repeat;width:100%;height:70px;"></div>
					</div>
					<script type="text/javascript">
						$("#productName").hide();$("#user").html($("#userControl"));$("#header").prepend($("#user, #logo"));
					</script>
				</c:if> --%>
			<div class="layout-nav">
				<ul id="menu" style="*white-space: nowrap; float: none;">
					<c:set var="firstMenu" value="true" />
					<c:forEach items="${fns:getMenuList()}" var="menu"
						varStatus="idxStatus">
						<c:if test="${menu.parent.id eq '1'&&menu.isShow eq '1'}">
							<li
								class="menu ${not empty firstMenu && firstMenu ? ' active' : ''}">
								<c:if test="${empty menu.href}">
									<a class="menu" href="javascript:"
										data-href="${ctx}/sys/menu/tree?parentId=${menu.id}"
										data-id="${menu.id}"><span>${menu.name}</span></a>
								</c:if> <c:if test="${not empty menu.href}">
									<a class="menu"
										href="${fn:indexOf(menu.href, '://') eq -1 ? ctx : ''}${menu.href}"
										data-id="${menu.id}" target="mainFrame"><span>${menu.name}</span></a>
								</c:if>
							</li>
							<c:if test="${firstMenu}">
								<c:set var="firstMenuId" value="${menu.id}" />
							</c:if>
							<c:set var="firstMenu" value="false" />
						</c:if>
					</c:forEach>
					<%--
						<shiro:hasPermission name="cms:site:select">
						<li class="dropdown">
							<a class="dropdown-toggle" data-toggle="dropdown" href="#">${fnc:getSite(fnc:getCurrentSiteId()).name}<b class="caret"></b></a>
							<ul class="dropdown-menu">
								<c:forEach items="${fnc:getSiteList()}" var="site"><li><a href="${ctx}/cms/site/select?id=${site.id}&flag=1">${site.name}</a></li></c:forEach>
							</ul>
						</li>
						</shiro:hasPermission> --%>
				</ul>
			</div>
			<!--/.nav-collapse -->

		</div>
		<div class="container-fluid">
			<div id="content" class="row-fluid">
				<div id="left">
					<%-- 
					<iframe id="menuFrame" name="menuFrame" src="" style="overflow:visible;" scrolling="yes" frameborder="no" width="100%" height="650"></iframe> --%>
				</div>
				<div id="openClose" class="close">&nbsp;</div>
				<div id="right">
					<iframe id="mainFrame" name="mainFrame" src=""
						style="overflow: visible;" scrolling="yes" frameborder="no"
						width="100%" height="650"></iframe>
				</div>
			</div>
			<div id="footer" class="row-fluid">
				Copyright &copy; 2012-${fns:getConfig('copyrightYear')}
				${fns:getConfig('productName')} - Powered By <a
					href="http://www.fosung.com/" target="_blank">FosungFrame</a>
				${fns:getConfig('version')}
			</div>
		</div>
	</div>
	<script type="text/javascript"> 
		var leftWidth = 200; // 左侧窗口大小
		var tabTitleHeight = 33; // 页签的高度
		var htmlObj = $("html"), mainObj = $("#main");
		var headerObj = $("#header"), footerObj = $("#footer");
		var frameObj = $("#left, #openClose, #right, #right iframe");
		function wSize(){
			var minHeight = 500, minWidth = 980;
			var strs = getWindowSize().toString().split(",");
			htmlObj.css({"overflow-x":strs[1] < minWidth ? "auto" : "hidden", "overflow-y":strs[0] < minHeight ? "auto" : "hidden"});
			mainObj.css("width",strs[1] < minWidth ? minWidth - 10 : "auto");
			frameObj.height((strs[0] < minHeight ? minHeight : strs[0]) - headerObj.height() - footerObj.height() - (strs[1] < minWidth ? 42 : 28));
			$("#openClose").height($("#openClose").height() - 5);// <c:if test="${tabmode eq '1'}"> 
			$(".jericho_tab iframe").height($("#right").height() - tabTitleHeight); // </c:if>
			wSizeWidth();
		}
		function wSizeWidth(){
			if (!$("#openClose").is(":hidden")){
				var leftWidth = ($("#left").width() < 0 ? 0 : $("#left").width());
				$("#right").width($("#content").width()- leftWidth - $("#openClose").width() -5);
			}else{
				$("#right").width("100%");
			}
		}// <c:if test="${tabmode eq '1'}"> 
		function openCloseClickCallBack(b){
			$.fn.jerichoTab.resize();
		} // </c:if>
	</script>
	<script src="${ctxStatic}/common/wsize.min.js" type="text/javascript"></script>

	<input type="hidden" id="_card_win" onclick="showCardWin()" />
	<input type="hidden" id="save_card_win" onclick="saveCardWin()" />
	<input type="hidden" id="_card_sucess" onclick="sucess()" />
	<input type="hidden" id="_card_sucess1" onclick="sucess1(personName)" />
	<input type="hidden" id="_card_error" onclick="error()" />
	<input type="hidden" id="_card_error1" onclick="error1()" />
	<input type="hidden" id="_card_error2" onclick="error2()" />

</body>
<script type="text/javascript">

</script>
</html>